///////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
#include <Material/MaterialManager.h>
#include <Material/Material.h>

//-----------------------------------------------------------------------------

MaterialManager::MaterialManager()
{
	m_materials.clear();
}

//-----------------------------------------------------------------------------

MaterialManager::~MaterialManager()
{
	ReleaseMaterials();
}

//-----------------------------------------------------------------------------

void	MaterialManager::ReleaseMaterials()
{
	std::vector<Material*>::iterator iter;
	for( iter = m_materials.begin(); iter != m_materials.end(); iter++ )
	{
		SAFE_DEL( *iter );
	}
}

//-----------------------------------------------------------------------------

void	MaterialManager::AddMaterial(Material* mat)
{
	m_materials.push_back( mat );
}

//-----------------------------------------------------------------------------

bool	MaterialManager::HaveMaterial( std::string name )
{
	std::vector<Material*>::iterator iter;
	for( iter = m_materials.begin(); iter != m_materials.end(); iter++ )
	{
		if( (*iter)->GetName() == name )
		{
			return true;
		}
	}
	return false;
}

//-----------------------------------------------------------------------------

Material*	MaterialManager::GetMaterial( std::string name )
{
	std::vector<Material*>::iterator iter;
	for( iter = m_materials.begin(); iter != m_materials.end(); iter++ )
	{
		if( (*iter)->GetName() == name )
		{
			return *iter;
		}
	}
	return NULL;
}

//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
